#ifndef TREE_H
#define TREE_H

#include "ZipNode.h"
#include "DirectoryNode.h"
#include "FileNode.h"

extern LoggerManager* g_logger;
/**
 * The tree to store data using recursive nodes
 */
class ZipTree
{
public:

    /**
     * Instantiate a Tree Structure
     */
    ZipTree();

    /**
     * Instantiate a Tree Structure with a root
     * @param root
     */
    ZipTree(const char* root);

    /**
     * Free the allocated memory
     */
    ~ZipTree();

    /**
     * Constructor copy
     * @param other
     */
    ZipTree(const ZipTree& other);

    /**
     * Add an element to the root node
     * @param element Name of element to be added
     * @param condition true if is directory,false if is file
     */
    void add(const char* element, bool condition);

    /**
     * Add an new node to the root node
     * @param node Node to be added
     */
    void add(ZipNode* node);

    /**
     * Add an element to the root node
     * @param newNodePath Name of node to be added
     * @param isDirectory true if is directory,false if is file
     * @param nodeToAddElement element is added to this node
     */
    void addToNode(const char* newNodePath, bool isDirectory, const char* nodeToAddElement);
    /**
     * Remove an element of the tree
     * @param element Element to remove
     */
    void remove(const char* element);
    /**
     * Set the root of the tree
     * @param node Node to replace current root
     */
    void setRoot(ZipNode* node);
    /**
     * Remove all data from this tree
     */
    void clear();
    /**
     * Checks if this tree is empty
     * @return true if this tree is empty,false other case
     */
    bool isEmpty() const;



    /**
     * Get the root of this tree
     * @return The node that is the current root
     */
    ZipNode* getRoot();


    /**
     * Prints the tree
     */
    void traverse(PF_Traverse traverseFunction)const;

//    char* charTraverse(ZipNode currentNode);

private:

    ZipNode* createNode(const char* element, bool condition);


private:
    /**
     * The recursive node of the tree
     */
    ZipNode* root_;
    /**
     * The logger
     */
    Logger* logger_;

};

#endif
